//
//  GYVisitorViewController.swift
//  Weibo
//
//  Created by vane on 16/8/9.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit

class GYVisitorViewController: UIViewController {

    var isLogin:Bool = GYUserAccountViewModel.sharedTools.isLogin
    
    var visitorView: GYVisitorView?

    
    override func loadView() {
        
        if isLogin {
            
            view = tableView
            
        }else{
            
            setupVisitorView()
            
        }
    }
    private func setupVisitorView(){
        
        visitorView = GYVisitorView()
        
        visitorView?.closure = {
            
           self.loginAction()
        }
        
        view = visitorView
        
        
        setupNav()
    }
    
    func setupNav(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")
    }

    func loginAction(){
        
//        print("登录或注册")
        let oauth = GYOAuthViewController()
        
        presentViewController(UINavigationController(rootViewController: oauth), animated: true, completion: nil)
        
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        

    }
    lazy var tableView:UITableView = UITableView()
    
}
